<template>
  <div>
    <wraptitle>
      <template v-slot:view-title>草稿箱（共计：{{ totalcount }}篇）</template>
    </wraptitle>
    <div class="careerplan-table-wrap">
      <el-table
        :data="careerplanList"
        border
        stripe
        size="mini"
        style="width: 100%"
      >
        <el-table-column
          prop="user_id.username"
          label="姓名"
          show-overflow-tooltip
          width="80"
        ></el-table-column>
        <el-table-column
          prop="user_id.studentid"
          label="学号"
          show-overflow-tooltip
          width="120"
        ></el-table-column>
        <el-table-column
          prop="user_id.userinfo.organization.orgname"
          label="班级"
          show-overflow-tooltip
          width="250"
        ></el-table-column>
        <el-table-column
          prop="title"
          label="职业规划标题"
          show-overflow-tooltip
          min-width="200"
        ></el-table-column>
        <el-table-column
          prop="timeslot_id.name"
          label="时段"
          show-overflow-tooltip
          width="100"
        ></el-table-column>
        <el-table-column
          prop="is_studymaster"
          label="是否考研"
          width="70"
          :formatter="formatStudy"
        >
        </el-table-column>
        <el-table-column
          prop="create_time"
          label="创建时间"
          width="128"
        ></el-table-column>
        <el-table-column
          prop="publish_time"
          label="提交时间"
          width="128"
        ></el-table-column>
        <el-table-column
          prop="update_time"
          label="更新时间"
          width="128"
        ></el-table-column>
        <el-table-column
          prop="status"
          fixed="right"
          label="状态"
          width="70"
          :formatter="formatStatus"
        >
          <template slot-scope="scope">
            <el-tag
              :type="scope.row.status == 1 ? 'success' : 'warning'"
              size="mini"
            >
              {{ formatStatus(scope.row.status) }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" width="90">
          <el-button
            size="mini"
            icon="el-icon-edit"
            type="primary"
            circle
            :disabled="disabled"
            @click="edit"
          ></el-button>
          <el-button
            size="mini"
            type="danger"
            icon="el-icon-delete"
            circle
            :disabled="disabled"
            @click="under"
          ></el-button>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页部分 -->
    <div class="pagination" v-show="totalcount > 10">
      <el-pagination
        background
        layout="prev, pager, next"
        :page-size="pagesize"
        @current-change="pageChange"
        :current-page.sync="currentPage"
        :total="totalcount"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import wraptitle from '@/components/content/WrapTitle'
import { getCareerPlanList } from '@/network/career'
export default {
  name: 'drafts',
  data() {
    return {
      pagenow: 1,
      pagesize: 10,
      // 当前页
      currentPage: 1,
      // 总页数
      totalcount: 0,
      careerplanList: [],
      disabled: true
    }
  },
  components: {
    wraptitle
  },
  created() {
    this.getCareerPlanList()
  },
  methods: {
    getCareerPlanList() {
      let params = {
        user_id: this.roleid >= 3 ? '' : this.$store.state.userid,
        pagenow: this.pagenow,
        status: 0
      }
      getCareerPlanList(params).then(res => {
        this.careerplanList = res.data.data
        if (res.code === 401) {
          this.$toast(res.message, 'error')
        }
      })
    },
    // 检测分页点击
    pageChange(currentPage) {
      this.pagenow = currentPage
      this.currentPage = currentPage
      this.getCareerPlanList()
    },
    edit() {},
    under() {},
    // 数据处理部分
    formatStatus(value) {
      return value == 1 ? '已提交' : '待提交'
    },
    formatStudy: function(row, column) {
      return row.is_studymaster == true ? '是' : '否'
    }
  }
}
</script>

<style></style>
